package com.ruoyi.web.controller.eamp;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.eamp.domain.EampCarLogs;
import com.ruoyi.eamp.domain.vo.LogsAndListAndUseVO;
import com.ruoyi.eamp.service.IEampCarLogsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 车辆记录表Controller
 * 
 * @author ruoyi
 * @date 2024-08-08
 */
@RestController
@RequestMapping("/eamp/car_logs")
public class EampCarLogsController extends BaseController
{
    @Autowired
    private IEampCarLogsService eampCarLogsService;


    /**
     * 查询车辆记录表列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:car_logs:list')")
    @GetMapping("/list")
    public TableDataInfo list(EampCarLogs eampCarLogs)
    {
        startPage();
        List<EampCarLogs> list = eampCarLogsService.selectEampCarLogsList(eampCarLogs);
        return getDataTable(list);
    }

    /**
     * 导出车辆记录表列表
     */
    @PreAuthorize("@ss.hasPermi('eamp:car_logs:export')")
    @Log(title = "车辆记录表", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, EampCarLogs eampCarLogs)
    {
        List<EampCarLogs> list = eampCarLogsService.selectEampCarLogsList(eampCarLogs);
        ExcelUtil<EampCarLogs> util = new ExcelUtil<EampCarLogs>(EampCarLogs.class);
        util.exportExcel(response, list, "车辆记录表数据");
    }

    /**
     * 获取车辆记录表详细信息
     */
    @PreAuthorize("@ss.hasPermi('eamp:car_logs:query')")
    @GetMapping(value = "/{logsId}")
    public AjaxResult getInfo(@PathVariable("logsId") Long logsId)
    {
        return success(eampCarLogsService.selectEampCarLogsByLogsId(logsId));
    }

    /**
     * 新增车辆记录表
     */
    @PreAuthorize("@ss.hasPermi('eamp:car_logs:add')")
    @Log(title = "车辆记录表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody EampCarLogs eampCarLogs)
    {
        return toAjax(eampCarLogsService.insertEampCarLogs(eampCarLogs));
    }

    /**
     * 修改车辆记录表
     */
    @PreAuthorize("@ss.hasPermi('eamp:car_logs:edit')")
    @Log(title = "车辆记录表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody EampCarLogs eampCarLogs)
    {
        return toAjax(eampCarLogsService.updateEampCarLogs(eampCarLogs));
    }

    /**
     * 删除车辆记录表
     */
    @PreAuthorize("@ss.hasPermi('eamp:car_logs:remove')")
    @Log(title = "车辆记录表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{logsIds}")
    public AjaxResult remove(@PathVariable Long[] logsIds)
    {
        return toAjax(eampCarLogsService.deleteEampCarLogsByLogsIds(logsIds));
    }

    @PreAuthorize("@ss.hasPermi('eamp:car_logs:log')")
    @GetMapping("/getlog")
    public TableDataInfo getlog(LogsAndListAndUseVO logsAndListAndUseVO)
    {
        startPage();
        List<LogsAndListAndUseVO> list =eampCarLogsService.getlog(logsAndListAndUseVO);
        return getDataTable(list);
    }


}
